package com.zhang.controller;


import com.zhang.service.ShoppingSysMemberService;
import com.zhang.units.Result;
import com.zhang.vo.MemberVo;
import com.zhang.vo.ProductVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhangD
 * @since 2021-07-13
 */
@RestController
@RequestMapping("/shopping-sys-member")
public class ShoppingSysMemberController {

    @Autowired
    private ShoppingSysMemberService shoppingSysMemberService;

    /**
     * 用户列表
     */
    @GetMapping("/select_member")
    public Result member(@RequestParam("memberName") String memberName,
                         @RequestParam("pageNo")int pageNo,
                         @RequestParam("pageSize") int pageSize){
        return Result.result200(shoppingSysMemberService.selectMember(memberName,pageNo,pageSize));
    }
    /**
     * 详细信息
     */
    @GetMapping("/member")
    public Result membertById(@RequestParam("userId") int userId){
        return  Result.result200(shoppingSysMemberService.getById(userId));
    }
    /**
     * 新增成员
     */
    @PostMapping("add_member")
    public  Result addMember(@RequestBody MemberVo memberVo){
        return Result.result500(shoppingSysMemberService.addMember(memberVo));
    }
    /**
     * 修改成员
     */
    @PostMapping("update_member")
    public  Result updateMember(@RequestBody MemberVo memberVo){
        return Result.result500(shoppingSysMemberService.updateMember(memberVo));
    }
    /**
     * 删除成员
     */
    @GetMapping("/delete_memberId")
    public  Result deleteMember1(@RequestParam("memberId") String memberId){
        return Result.result200(shoppingSysMemberService.removeById(memberId));
    }
    /**
     * 删除成员
     */
    @GetMapping("/delete_memberIds")
    public  Result deleteMember2(@RequestParam("memberIds") List<String> memberIds){
        return Result.result200(shoppingSysMemberService.removeByIds(memberIds));
    }
}

